/**
 * @function namespace/signatrue - Component type : Control type : Parser.formskin : Parser.impl : html
 * conf - configuration properties for layout
 * prop - properties
 * parentconf - parent element conf
 * parentprop - parent element prop
 */
/*Parser["control:select:default:Json2htmlParser:html"] = function(conf, prop, parentconf, parentprop) {
	Parser.log(JSON.stringify(parentconf));
	Parser.log(JSON.stringify(parentprop));
	
	var dpval = prop[prop["dataprovider"]];
	
	return '<span class="label"'+
			(prop["i18ntip-"+Parser.lang] ? (' original-title="'+prop["i18ntip-"+Parser.lang]+'"') : '')
			+ '>'
			+ (required ? '<span class="xh">*</span>' : '')
			+ prop["i18nname-" + Parser.lang] + '</span>'
			+ '<span class="item"><select '
			+ (prop.disabled=='1' ? ' disabled="true"' : '')
			+ (prop.style ? ' style="'+prop.style+'"' : '')
			+ (' class="select '+(prop.classNames ? prop.classNames : '')+'"')
			+ ' size="'+(prop.size||'1')+'"'
			+ ' id="' + conf.id +'"'
			+ ' ng-model="b.'+prop["databinding-realvalue"]+'"'
			+ ' onchange="fmdf.onchangeOfSelect(\''+conf.id+'\')"'
			+ '>'
			//+ '<option ng-repeat="i in m.enu.'+prop["dataprovider-dict"]+'" value="{{i.key}}"'
			+ '<option ng-repeat="i in m.enu[\''+dpval+'\']" value="{{i[0]}}"'
				+' ng-selected="{{i[0]==b.'+prop["databinding-realvalue"]+'}}">{{i[1]}}</option>'
			+ '</select>'
			+ '<input type="hidden"'
			+ ' value="{{b.'+prop["databinding-realvalue"]+'}}"'
			+ ' desc="'+ prop["i18nname-" + Parser.lang] +'"'
			+ ' name="' + conf.id+ '"'
			+ ' databinding="'+ prop["databinding-realvalue"] +'"'
			+ (prop["processbinding-realvalue"] ? ' binding="'+ prop["processbinding-realvalue"] + '"' : '')
			+ '/>'
			+ '<input type="hidden"'
			+ ' value="{{b.'+prop["databinding-displayvalue"]+'}}"'
			+ ' desc="'+ prop["i18nname-" + Parser.lang] +'"'
			+ ' name="' + conf.id+ '"'
			+ ' databinding="'+ prop["databinding-displayvalue"] +'"'
			+ (prop["processbinding-displayvalue"] ? ' binding="'+ prop["processbinding-displayvalue"] + '"' : '')
			+ '/>'
			+ '</span>';
};*/

/*Parser["control:select:bootstrap-blue:Json2htmlParser:html"] = function(conf, prop, parentconf, parentprop) {
	Parser.log(JSON.stringify(parentconf));
	Parser.log(JSON.stringify(parentprop));
	
	var dpval = prop[prop["dataprovider"]];
	var fmdcols = parseInt(parentconf.fmdcols);
	var cols = [1,fmdcols-1];
	if(fmdcols>3) {
		cols = [2,fmdcols-2];
	}
	return '<div class="col-md-'+cols[0]+'">'+
		    '<p'+
		    (prop["i18ntip-"+Parser.lang] ? (' original-title="'+prop["i18ntip-"+Parser.lang]+'"') : '') +
		    '>'+prop["i18nname-"+Parser.lang]+
		    (required ? '<span class="xh">*</span>' : '') +
		    '</p>'+
		    '</div>'+
		    '<div class="col-md-'+cols[1]+'">'
			+ '<select '
			+ (prop.disabled=='1' ? ' disabled="true"' : '')
			+ (prop.style ? ' style="'+prop.style+'"' : '')
			+ (' class="form-control '+(prop.classNames ? prop.classNames : '')+'"')
			+ ' size="'+(prop.size||'1')+'"'
			+ (prop.multiple=='1' ? ' multiple="multiple"':'')
			+ ' id="' + conf.id +'"'
			+ ' ng-model="b.'+prop["databinding-realvalue"]+'"'
			+ ' onchange="fmdf.onchangeOfSelect(\''+conf.id+'\')"'
			+ '>'
			+ '<option ng-repeat="i in m.enu[\''+dpval+'\']" value="{{i[0]}}"'
			+(prop.multiple=='1' ? ' ng-selected="{{b.'+prop["databinding-realvalue"]+'.join(\',\').indexOf(i[0])!=-1}}">{{i[1]}}</option>' : ' ng-selected="{{i[0]==b.'+prop["databinding-realvalue"]+'}}">{{i[1]}}</option>')
			+ '</select>'
			+ '<input type="hidden"'
			+ ' value="{{b.'+prop["databinding-realvalue"]+'}}"'
			+ ' desc="'+ prop["i18nname-" + Parser.lang] +'"'
			+ ' name="' + conf.id+ '"'
			+ ' databinding="'+ prop["databinding-realvalue"] +'"'
			+ (prop["processbinding-realvalue"] ? ' binding="'+ prop["processbinding-realvalue"] + '"' : '')
			+ '/>'
			+ '<input type="hidden"'
			+ ' value="{{b.'+prop["databinding-displayvalue"]+'}}"'
			+ ' desc="'+ prop["i18nname-" + Parser.lang] +'"'
			+ ' name="' + conf.id+ '"'
			+ ' databinding="'+ prop["databinding-displayvalue"] +'"'
			+ (prop["processbinding-displayvalue"] ? ' binding="'+ prop["processbinding-displayvalue"] + '"' : '')
			+ '/>'
			+ '</div>';
};*/


Parser["control:select:default:Json2htmlParser:html"] = function(confs) {
	var s = "";
	for (var c in confs) {
		var conf = confs[c];
		var prop = conf.id ? Parser.props[conf.id] : {};
		Parser.log(JSON.stringify(conf));
		Parser.log(JSON.stringify(prop));
		Parser.parseDataProvider(conf.id);
		var required = Parser.parseValidator(conf.id);
		Parser.parseI18ntip(conf.id);
		var data = {};
		data.style = Parser.cssDisplay(prop.display)+(prop.style?prop.style:"");
		var transform = {"tag":"i"};
		var fmdcols = parseInt(conf.fmdcols);
		var cols = [1,fmdcols-1];
		if(fmdcols>3) {
			cols = [2,fmdcols-2];
		}
		
		/*+'<select '
			+ (prop.disabled=='1' ? ' disabled="true"' : '')
			+ (prop.style ? ' style="'+prop.style+'"' : '')
			+ (' class="select '+(prop.classNames ? prop.classNames : '')+'"')
			+ ' size="'+(prop.size||'1')+'"'
			+ ' id="' + conf.id +'"'
			+ ' ng-model="b.'+prop["databinding-realvalue"]+'"'
			+ ' onchange="fmdf.onchangeOfSelect(\''+conf.id+'\')"'
			+ '>'
			+ '<option ng-repeat="i in m.enu[\''+conf.id+'\']" value="{{i[0]}}"'
				+' ng-selected="{{i[0]==b.'+prop["databinding-realvalue"]+'}}">{{i[1]}}</option>'
			+ '</select>'*/
		
		var selectHtml="";
		if(prop.multiple=='1'){
			selectHtml= '<select '
			+ (prop.disabled=='1' ? ' disabled="true"' : '')
			+ (prop.style ? ' style="'+prop.style+'"' : '')
			+ (' class="form-control '+(prop.classNames ? prop.classNames : '')+'"')
			+ (prop.multiple=='1' ? ' size="'+(prop.size>5 ? '5' : prop.size)+'"':' size="1"')
			+ (prop.multiple=='1' ? ' multiple="multiple"':'')
			+ ' id="' + conf.id +'"'
			+ ' ng-model="b.'+prop["databinding-realvalue"]+'"'
			+ ' onchange="fmdf.onchangeOfSelect(\''+conf.id+'\')"'
			+ '>'
			+ '<option class="ng-cloak1" ng-repeat="i in m.enu[\''+conf.id+'\']" value="{{i[0]}}"'
			+(prop.multiple=='1' ? ' ng-selected="{{b.'+prop["databinding-realvalue"]+'.join(\',\').indexOf(i[0])!=-1}}">{{i[1]}}</option>' : ' ng-selected="{{i[0]==b.'+prop["databinding-realvalue"]+'}}">{{i[1]}}</option>')
			+ '</select>'
			+ '<input "text" style="display:none;"'
			+ ' value="{{b.'+prop["databinding-realvalue"]+'}}"'
			+ ' desc="'+ prop["i18nname-" + Parser.lang] +'"'
			+ ' name="' +(conf.id+'-h')+'"'
			+ ' databinding="'+ prop["databinding-realvalue"] +'"'
			//+ (prop["processbinding-realvalue"] ? ' binding="'+ prop["processbinding-realvalue"] + '"' : '')
			+ '/>'
			+ '<input "text" style="display:none;"'
			+ ' value="{{b.'+prop["databinding-displayvalue"]+'}}"'
			+ ' desc="'+ prop["i18nname-" + Parser.lang] +'"'
			+ ' name="' + conf.id+ '"'
			+ ' databinding="'+ prop["databinding-displayvalue"] +'"'
			//+ (prop["processbinding-displayvalue"] ? ' binding="'+ prop["processbinding-displayvalue"] + '"' : '')
			+ '/>';
		}else{
			selectHtml='<div style="width: 100%; position: relative;'+(prop.style ? prop.style : '')+'" class="'+(prop.classNames ? prop.classNames : '')+'">'
				+'<div '+(prop.disabled=='1' ? '' : 'class="form-control"')
				+(prop.disabled=='1' ? '' : 'onclick="toggleSelect(this,event)"')+' >'
				+(prop.disabled=='1' ? '<input type="text" readonly="readonly" class="form-control" ng-model="b.'+ prop["databinding-displayvalue"] +'" databinding="'+ prop["databinding-displayvalue"] +'"/>' : '<span class="select-span">{{b.'+prop["databinding-displayvalue"]+'}}</span>')
				+'<span class="caret select-caret"></span>'
				+'</div>'
				+'<select id="' + conf.id +'" '
				+ ' ng-model="b.'+prop["databinding-realvalue"]+'"'
				+ ' onchange="fmdf.onchangeOfSelect(\''+conf.id+'\')"'
				+' size="0" size1="{{(m.enu[\''+conf.id+'\'].length >5 ? 5 : (m.enu[\''+conf.id+'\'].length==1?m.enu[\''+conf.id+'\'].length+1:m.enu[\''+conf.id+'\'].length+2))}}" class="form-control form-control-select hide" onclick="toggleDivVal(this)">'
				+' <option value=""></option>'
				+'<option class="ng-cloak1" ng-repeat="i in m.enu[\''+conf.id+'\']" value="{{i[0]}}"'
				+' ng-selected="{{i[0]==b.'+prop["databinding-realvalue"]+'}}">{{i[1]}}</option>'
				+ '</select>'
				+ '<input type="hidden"'
				+ ' value="{{b.'+prop["databinding-realvalue"]+'}}"'
				+ ' desc="'+ prop["i18nname-" + Parser.lang] +'"'
				+ ' name="' + conf.id+ '"'
				+ ' databinding="'+ prop["databinding-realvalue"] +'"'
				//+ (prop["processbinding-realvalue"] ? ' binding="'+ prop["processbinding-realvalue"] + '"' : '')
				+ '/>'
				+ '<input type="hidden"'
				+ ' value="{{b.'+prop["databinding-displayvalue"]+'}}"'
				+ ' desc="'+ prop["i18nname-" + Parser.lang] +'"'
				+ ' name="' + conf.id+ '"'
				+ ' databinding="'+ prop["databinding-displayvalue"] +'"'
				//+ (prop["processbinding-displayvalue"] ? ' binding="'+ prop["processbinding-displayvalue"] + '"' : '')
				+ '/>'
				
				+ '</div>';
		}
		
		transform.html = '<span class="label col-md-'+cols[0]+'"'
			+ (data.style ? ' style="'+data.style+'"' : '')
			+ '><p'
			+ (prop["i18ntip-"+Parser.lang] ? (' title="'+prop["i18ntip-"+Parser.lang]+'"') : '')
			+ (prop.hideLabel=='1' ? ' style="display:none;"' : '')
			+ '>'
			+ (required ? '<span class="xh">*</span>' : '')
			+ prop["i18nname-" + Parser.lang] 
			+ (prop["i18ntip-"+Parser.lang] ? ('&nbsp;<i class="glyphicon glyphicon-question-sign"></i>') : '')
			+ '</p>'+'</span>'
			+ '<span class="item cellborder col-md-'+cols[1]+'"'
			+ (data.style ? ' style="'+data.style+'"' : '')
			+ '>'
			+ selectHtml
			+ (prop.attachment=='1' ? '<span class="attachspan" attach-tag="'+(prop.attachmentTag || conf.id)+'">'

					+ (prop.attachmentEditable=='1' ? '<button class="btnupload" title="'+fmd_i18n_prop_upattach+'">&nbsp;'+fmd_i18n_modules.input.attachment+'&nbsp;</button>' : '')
					+ '</span>' : '')
			+ '</span>';
		var wrapper = json2html.transform(data, transform);
		s += wrapper.substr(0, wrapper.length-4).substr(3);
	}
	return s;
};

Parser["control:select:bootstrap-blue:Json2htmlParser:html"] = function(confs) {
	var s = "";
	for (var c in confs) {
		var conf = confs[c];
		var prop = conf.id ? Parser.props[conf.id] : {};
		Parser.log(JSON.stringify(conf));
		Parser.log(JSON.stringify(prop));
		Parser.parseDataProvider(conf.id);
		var required = Parser.parseValidator(conf.id);
		Parser.parseI18ntip(conf.id);
		var data = {};
		var transform = {"tag":"i"};
		var fmdcols = parseInt(conf.fmdcols);
		var cols = [1,fmdcols-1];
		if(fmdcols>3) {
			cols = [2,fmdcols-2];
		}
		var selectHtml="";
		if(prop.multiple=='1'){
			selectHtml= '<select '
			+ (prop.disabled=='1' ? ' disabled="true"' : '')
			+ (prop.style ? ' style="'+prop.style+'"' : '')
			+ (' class="ng-cloak1 form-control '+(prop.classNames ? prop.classNames : '')+'"')
			+ (prop.multiple=='1' ? ' size="'+(prop.size>5 ? '5' : prop.size)+'"':' size="1"')
			+ (prop.multiple=='1' ? ' multiple="multiple"':'')
			+ ' id="' + conf.id +'"'
			+ ' ng-model="b.'+prop["databinding-realvalue"]+'"'
			+ ' onchange="fmdf.onchangeOfSelect(\''+conf.id+'\')"'
			+ '>'
			+ '<option class="ng-cloak1" ng-repeat="i in m.enu[\''+conf.id+'\']" value="{{i[0]}}"'
			+(prop.multiple=='1' ? ' ng-selected="{{b.'+prop["databinding-realvalue"]+'.join(\',\').indexOf(i[0])!=-1}}">{{i[1]}}</option>' : ' ng-selected="{{i[0]==b.'+prop["databinding-realvalue"]+'}}">{{i[1]}}</option>')
			+ '</select>'
			+ '<input "text" style="display:none;"'
			+ ' value="{{b.'+prop["databinding-realvalue"]+'}}"'
			+ ' desc="'+ prop["i18nname-" + Parser.lang] +'"'
			+ ' name="' +(conf.id+'-h')+'"'
			+ ' databinding="'+ prop["databinding-realvalue"] +'"'
			//+ (prop["processbinding-realvalue"] ? ' binding="'+ prop["processbinding-realvalue"] + '"' : '')
			+ '/>'
			+ '<input "text" style="display:none;"'
			+ ' value="{{b.'+prop["databinding-displayvalue"]+'}}"'
			+ ' desc="'+ prop["i18nname-" + Parser.lang] +'"'
			+ ' name="' + conf.id+ '"'
			+ ' databinding="'+ prop["databinding-displayvalue"] +'"'
			//+ (prop["processbinding-displayvalue"] ? ' binding="'+ prop["processbinding-displayvalue"] + '"' : '')
			+ '/>';
		}else{
			selectHtml='<div style="width: 100%; position: relative;'+(prop.style ? prop.style : '')+'" class="'+(prop.classNames ? prop.classNames : '')+'">'
				+'<div '+(prop.disabled=='1' ? '' : 'class="ng-cloak1 form-control"')
				+(prop.disabled=='1' ? '' : 'onclick="toggleSelect(this,event)"')+' >'
				+(prop.disabled=='1' ? '<input type="text" readonly="readonly" class="form-control" ng-model="b.'+ prop["databinding-displayvalue"] +'" databinding="'+ prop["databinding-displayvalue"] +'"/>' : '<span class="select-span">{{b.'+prop["databinding-displayvalue"]+'}}</span>')
				+'<span class="caret select-caret"></span>'
				+'</div>'
				+'<select id="' + conf.id +'" '
				+ ' ng-model="b.'+prop["databinding-realvalue"]+'"'
				+ ' onchange="fmdf.onchangeOfSelect(\''+conf.id+'\')"'
				+' size="0" size1="{{(m.enu[\''+conf.id+'\'].length >5 ? 5 : (m.enu[\''+conf.id+'\'].length==1?m.enu[\''+conf.id+'\'].length+1:m.enu[\''+conf.id+'\'].length+2))}}" class="form-control form-control-select hide" onclick="toggleDivVal(this)">'
				+' <option value=""></option>'
				+'<option class="ng-cloak1" ng-repeat="i in m.enu[\''+conf.id+'\']" value="{{i[0]}}"'
				+' ng-selected="{{i[0]==b.'+prop["databinding-realvalue"]+'}}">{{i[1]}}</option>'
				+ '</select>'
				+ '<input type="hidden"'
				+ ' value="{{b.'+prop["databinding-realvalue"]+'}}"'
				+ ' desc="'+ prop["i18nname-" + Parser.lang] +'"'
				+ ' name="' + conf.id+ '"'
				+ ' databinding="'+ prop["databinding-realvalue"] +'"'
				//+ (prop["processbinding-realvalue"] ? ' binding="'+ prop["processbinding-realvalue"] + '"' : '')
				+ '/>'
				+ '<input type="hidden"'
				+ ' value="{{b.'+prop["databinding-displayvalue"]+'}}"'
				+ ' desc="'+ prop["i18nname-" + Parser.lang] +'"'
				+ ' name="' + conf.id+ '"'
				+ ' databinding="'+ prop["databinding-displayvalue"] +'"'
				//+ (prop["processbinding-displayvalue"] ? ' binding="'+ prop["processbinding-displayvalue"] + '"' : '')
				+ '/>'
				+ '</div>';
		}
		transform.html = '<div class="col-md-'+cols[0]+'">'+
		    '<p'+
		    (prop["i18ntip-"+Parser.lang] ? (' title="'+prop["i18ntip-"+Parser.lang]+'"') : '') +
		    '>'+prop["i18nname-"+Parser.lang]+
		    (required ? '<span class="xh">*</span>' : '') +
		    (prop["i18ntip-"+Parser.lang] ? ('&nbsp;<i class="glyphicon glyphicon-question-sign"></i>') : '')+
		    '</p>'+
		    '</div>'+
		    '<div class="col-md-'+cols[1]+'">'
			+ selectHtml
			+ (prop.attachment=='1' ? '<span class="attachspan" attach-tag="'+(prop.attachmentTag || conf.id)+'">'
					+ (prop.attachmentEditable=='1' ? '<button class="btnupload" title="'+fmd_i18n_prop_upattach+'">&nbsp;'+fmd_i18n_modules.input.attachment+'&nbsp;</button>' : '')
					+ '</span>' : '')
			+ '</div>';
		var wrapper = json2html.transform(data, transform);
		s += wrapper.substr(0, wrapper.length-4).substr(3);
	}
	return s;
};

/*Parser["control:select:default:Json2htmlParser:html"] = function(confs) {
	var s = "";
	for (var c in confs) {
		var conf = confs[c];
		var prop = conf.id ? Parser.props[conf.id] : {};
		Parser.log(JSON.stringify(conf));
		Parser.log(JSON.stringify(prop));
		Parser.parseDataProvider(conf.id);
	    var data = {};
		var transform = {"tag":"i"};
		var fmdcols = parseInt(conf.fmdcols);
		Parser.log("input fmdcols="+fmdcols);
		var cols = [1,fmdcols-1];
		if(fmdcols>3) {
			cols = [2,fmdcols-2];
		}
		var selectHtml="";
		if(prop.multiple=='1'){
			selectHtml= '<select '
			+ (prop.disabled=='1' ? ' disabled="true"' : '')
			+ (prop.style ? ' style="'+prop.style+'"' : '')
			+ (' class="form-control '+(prop.classNames ? prop.classNames : '')+'"')
			+ (prop.multiple=='1' ? ' size="'+(prop.size>5 ? '5' : prop.size)+'"':' size="1"')    
			+ (prop.multiple=='1' ? ' multiple="multiple"':'')
			+ ' id="' + conf.id +'"'
			+ ' ng-model="b.'+prop["databinding-realvalue"]+'"'
			+ ' onchange="fmdf.onchangeOfSelect(\''+conf.id+'\')"'
			+ '>'
			+ '<option class="ng-cloak1" ng-repeat="i in m.enu[\''+conf.id+'\']" value="{{i[0]}}"'
			+(prop.multiple=='1' ? ' ng-selected="{{b.'+prop["databinding-realvalue"]+'.join(\',\').indexOf(i[0])!=-1}}">{{i[1]}}</option>' : ' ng-selected="{{i[0]==b.'+prop["databinding-realvalue"]+'}}">{{i[1]}}</option>')
			+ '</select>';
		}else{
			selectHtml='<div style="width: 100%; position: relative;'+(prop.style ? prop.style : '')+'" class="'+(prop.classNames ? prop.classNames : '')+'">'
				+'<div class="form-control '+(prop.disabled=='1' ? 'disabledDiv' : '')+'" '+(prop.disabled=='1' ? '' : 'onclick="toggleSelect(this,event)"')+' ><span class="select-span"></span><span class="caret select-caret"></span></div>'
				+'<select id="' + conf.id +'" '
				+ ' ng-model="b.'+prop["databinding-realvalue"]+'"'
				+ ' onchange="fmdf.onchangeOfSelect(\''+conf.id+'\')"'
				+'size="0" size1="{{(m.enu[\''+conf.id+'\'].length >5 ? 5 : m.enu[\''+conf.id+'\'].length)}}" class="form-control form-control-select hide" onclick="toggleDivVal(this)">'
				+'<option class="ng-cloak1" ng-repeat="i in m.enu[\''+conf.id+'\']" value="{{i[0]}}"'
				+' ng-selected="{{i[0]==b.'+prop["databinding-realvalue"]+'}}">{{i[1]}}</option>'
				+ '</select></div>';
		}
		transform.html = 
			'<span class="label col-md-'+cols[0]+'"'+'<p'+
			(prop["i18ntip-"+Parser.lang] ? (' original-title="'+prop["i18ntip-"+Parser.lang]+'"') : '')
			+ '>'
			+ (required ? '<span class="xh">*</span>' : '')
			+ prop["i18nname-" + Parser.lang] +'</p>'+'</span>'+
		    '<div class="col-md-'+cols[1]+'">'
			+ selectHtml
			+ '<input type="hidden"'
			+ ' value="{{b.'+prop["databinding-realvalue"]+'}}"'
			+ ' desc="'+ prop["i18nname-" + Parser.lang] +'"'
			+ ' name="' + conf.id+ '"'
			+ ' databinding="'+ prop["databinding-realvalue"] +'"'
			//+ (prop["processbinding-realvalue"] ? ' binding="'+ prop["processbinding-realvalue"] + '"' : '')
			+ '/>'
			+ '<input type="hidden"'
			+ ' value="{{b.'+prop["databinding-displayvalue"]+'}}"'
			+ ' desc="'+ prop["i18nname-" + Parser.lang] +'"'
			+ ' name="' + conf.id+ '"'
			+ ' databinding="'+ prop["databinding-displayvalue"] +'"'
			//+ (prop["processbinding-displayvalue"] ? ' binding="'+ prop["processbinding-displayvalue"] + '"' : '')
			+ '/>'
			+ '</span>';
		var wrapper = json2html.transform(data, transform);
		s += wrapper.substr(0, wrapper.length-4).substr(3);
	}
	return s;
};*/